<?php

require_once 'init.php';
require_once 'cf/api/cart.php';

if (!empty($_POST))
{
	cf\api\cart\clear();
	$products = array();
	foreach ($_POST['id'] as $pid) {
		if (!array_key_exists('delete',$_POST) || !array_key_exists($pid,$_POST['delete'])) {
			$products[$pid] = $_POST['amount'][$pid];
		}
	}
	cf\api\cart\set($products);
	header('Location: /cart');
}

$smarty->assign('cart', cf\api\cart\getList());
show(
	'cart', 
	'Корзина', 
	array(array('name'=>'Корзина'))
);

?>